<template>
    <div class="flex_row">
        <el-button class="ml5" @click="onClickScreenshot" type="primary">截图</el-button>
        <img v-if="ctx.screenUrl.length != 0" :src="ctx.screenUrl" />
    </div>
</template>

<script lang="ts" setup>
import { request } from '@/service/device';
import { runAction } from '@/utils/ui';
import { reactive } from 'vue';
import { useRoute } from 'vue-router';


const route = useRoute();

const id = parseInt(route.query.id as string);

const SCREEN_SHOT = "screen.shot";
const GET_VERSION = "get.version";

interface Ctx {
    screenUrl: string,
}

const ctx = reactive<Ctx>({
    screenUrl: ''
});

async function onClickScreenshot() {
    await runAction('截图', '', async () => {
        const resp = await request(id, SCREEN_SHOT, 10);
        const url = await resp.objectUrl();
        ctx.screenUrl = url;
    });
}

</script>
